package com.itcast.Array;

import com.itcast.arrays.Teacher;

import java.util.Arrays;
import java.util.Comparator;

public class Test5 {

    public static void main(String[] args) {
        Student[] arr = {
                new Student("aaa", 18, 170, 65, 100),
                new Student("bbb", 17, 179, 70, 10),
                new Student("ccc", 15, 177, 55, 20),
                new Student("ddd", 19, 176, 50, 15),
                new Student("eee", 16, 180, 52, 90),
        };
        //MyArrays.sort(arr);
        MyArrays.sort(arr, new A<Student>() {
            @Override
            public int aaa(Student left, Student right) {
                return left.getAge() - right.getAge();
            }
        });

        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

        Teacher[] tArr = new Teacher[]{
                new Teacher("梅军建", 1000),
                new Teacher("军建", 100),
                new Teacher("梅建", 10000),
                new Teacher("梅军", 100000000),
        };
        //MyArrays.sort(tArr);
        Arrays.sort(tArr, new Comparator<Teacher>() {
            @Override
            public int compare(Teacher left, Teacher right) {
                return left.getSalary() - right.getSalary();
            }
        });

        for (int i = 0; i < tArr.length; i++) {
            System.out.println(tArr[i]);
        }

    }
}
